import java.util.Scanner;

import jssc.SerialPort;
import jssc.SerialPortException;


public class arduinoComm2 {

	public static void main(String[] args) throws InterruptedException {

		// Define Port
		SerialPort serialPort = new SerialPort("COM3");

		try {
			// Open Serial Port and set Parameters
			serialPort.openPort();
			serialPort.setParams(115200, 8, 1, 0);

			// Create Scanner to read from Console
			Scanner reader = new Scanner(System.in);

			while (true) {
					if (reader.hasNext()) {

					String outputData = reader.next() + '\n';
					serialPort.writeString(outputData);
					System.out.println(outputData +" <= sent!");
				}

			}

		} catch (SerialPortException ex) {

			System.out.println(ex);

		}
	}

}